home *** CD-ROM | disk | FTP | other *** search
- Date: Wed, 27 Jul 94 09:44:34 BST
- From: d.oakley.kid0111@oasis.icl.co.uk
- Subject: Raster scrolling background windows
- To: gem-list@world.std.com
- Precedence: bulk
-
- Hi!
-
- I've managed the above in my StormTracker program. I'm not at an
- Atari or near Atari manuals, so the following example is in a
- mix of C and pseudo-code:
-
- typedef struct realscreen {
- int rx,ry; // where we are on the big screen
- // ie. the whole document
- int window; // the window we're mapping it into
- }
-
- realscreen rs;
-
- main()
- {
- ...
- scroll_down(16); // user pressed the DOWN button
- ...
- }
-
- void scroll_down(int dist)
- {
- GRECT r;
- rs.rx +=dist; // update our position in the document
-
- get_first_rectangle(rs.window,&r);
-
- while(r.w!=0 && r.h!=0) // we have a rectangle to update
- {
- scroll_block(r.x,r.y+dist,r.w,r.h-dist,dist);
- // ^^ a bit of code which copies the given
- // rectangle up dist pixels
-
- draw_window(r.x,r.y+r.h-dist,r.w,dist);
- // ^^ redraw the bit of window which
- // has just become visible
-
- get_next_rectangle(rs.window,&r);
- }
- }
-
- Right. This is what it does.
-
- You treat each bit of window you need to redraw as the extent of the
- window. So if before the scroll your window looks like:
-
- +---------------+
- | the cow jumped| |
- | and yelled "He| | |
- | I've no idea w| | we can copy this to here: |
- |funny that, I n| |
- +---------------+
-
- and we scroll this bit of window up it becomes
-
- +---------------+
- | and yelled "He|
- | I've no idea w|
- |funny that, I n|
- |funny that, I n| <- this line now needs redrawing
- +---------------+
- and then
-
- +---------------+
- | and yelled "He|
- | I've no idea w|
- |funny that, I n|
- |thought that co|
- +---------------+
-
- As long as you have written a chunk of code which can handle redrawing any
- bit of screen (you should have that), scrolling background windows is
- simply a case of calculating which bit moves for each redraw rectangle,
- moving it can redrawing what is left.
-
- Hope that helps
-
- David
- ------------------------------------------------------------------
- David Oakley, Sponsored Student, ICL MSPL, Stoke-on-Trent, England
- ------------------------------------------------------------------
-
-